import ajax from './ajax';
import '../style/form.css';


const form = document.forms.login;

form.onsubmit = function (e) {
  e.preventDefault();

  ajax('post', 'http://127.0.0.1/api/login',{
    username: form.uid.value,
    password: form.pwd.value,
  }).then(result => {
  console.log(result);
  if(result.flag){
    alert('登录成功');
    localStorage.setItem('token', result.token);
    location.assign('index.html')
  }else{
    alert('登陆失败');
  }
})
}
